package com.lst.tools.oss.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.aliyun.oss.OSSClient;
import com.aliyun.oss.common.auth.CredentialsProvider;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.lst.tools.oss.properties.OssProperties;

/**
 * @author: Frank
 * @date: 2018/3/21 11:54
 * @version: V1.0
 */
@Configuration
public class OssConfig {

    @Autowired
    private OssProperties ossProperties;

    @Bean
    public OSSClient getInstance() {
        return new OSSClient(ossProperties.getEnPoint(), getCredentialsProvider(), null);
    }

    @Bean
    public CredentialsProvider getCredentialsProvider() {
        return new DefaultCredentialProvider(ossProperties.getAccessKeyId(), ossProperties.getAccessKeySecret());
    }
}
